package com.yxw.bamboo;

import com.yxw.bamboo.core.NetWorkMonitor;
import com.yxw.bamboo.core.NetworkContext;
import com.yxw.bamboo.core.spring.SpringUtil;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
public class NetWorkMonitorFactory {

    public NetWorkMonitor createNetWork(NetworkContext networkContext)
    {
        NetWorkMonitor netWorkmsMonitor=(NetWorkMonitor) SpringUtil.getBean("netWorkMonitor");
        netWorkmsMonitor.setNetworkContext(networkContext);
        return netWorkmsMonitor;
    }

    @Bean("netWorkMonitor")
    @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public NetWorkMonitor getNetWorkMonitor() {
        return new NetWorkMonitor();
    }
}
